package com.lotter.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lotter.common.context.YcContext;
import com.lotter.common.util.DateUtil;
import com.lotter.context.GlobConst;
import com.lotter.dao.LotterOrderDao;
import com.lotter.model.lotterorder.LotterOrderlist;

/**
 * 彩票订单
 * @author panguixiang
 *
 */
@Service
public class LotterOrderService {

	@Autowired
	private LotterOrderDao lotterOrderDao;
	
	
	public Map<String,Object> getLotterOrderPage(String startdatestr, String enddatestr,String mobile,
			Integer page,Integer rows,Map<String,Object> result) throws Exception {
    	page=page==null?page=1:page;
		int start=(page-1)*rows;
		
		Date startdate=null,enddate=null;
		if(StringUtils.isNotBlank(startdatestr)) {
			startdate = DateUtil.stringToDate(startdatestr, YcContext.DATE_STR_PATTERN);
		}
		if(StringUtils.isNotBlank(enddatestr)) {
			enddate = DateUtil.stringToDate(enddatestr, YcContext.DATE_STR_PATTERN);
		}
		List<LotterOrderlist> list = lotterOrderDao.getLotterOrderPage(mobile,startdate,enddate, start, rows);
		result.put(GlobConst.page_row,list);//rows键 存放每页记录 list  
		result.put(GlobConst.page_total, lotterOrderDao.getLotterOrderCount(mobile,startdate,enddate));//total键 存放总记录数，必须的  
        return result;
    }
}
